package com.heima.wemedia.admin;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CheckNewDto;
import com.heima.model.wemedia.dtos.NewsDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: JW
 * @Description: TODO
 * @DateTime: 2022-02-18 21:17
 **/
@RestController
@RequestMapping("/api/v1/news")
public class NewsController {


    @Autowired
    private WmNewsService wmNewsService;

    /**
     * @Author: JW
     * @Description:  TODO 查询
     * @Date: 21:23 2022-02-18
     * @Param: [wmNewsDto]
     * @return: com.heima.model.common.dtos.PageResponseResult
    **/
    @PostMapping("/list_vo")
    public PageResponseResult find(@RequestBody NewsDto newsDto){

        return wmNewsService.find(newsDto);
    }

    /**
     * @Author: JW
     * @Description:  TODO 驳回
     * @Date: 11:25 2022-02-19
     * @Param: [checkNewDto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody CheckNewDto checkNewDto){

        return wmNewsService.authFail(checkNewDto);

    }

    /**
     * @Author: JW
     * @Description:  TODO 通过审核
     * @Date: 11:35 2022-02-19
     * @Param: [checkNewDto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody CheckNewDto checkNewDto){

        return wmNewsService.authPass(checkNewDto);

    }

    /**
     * @Author: JW
     * @Description:  TODO 查看单个文章
     * @Date: 14:50 2022-02-19
     * @Param: [id]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @GetMapping("/one_vo/{id}")
    public ResponseResult getOneNews(@PathVariable Integer id){

        return wmNewsService.getOneNews(id);
    }
}
